<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>根据页面宽度改变背景变色</title>
    <style>
        /* 宽度小于等于539px的时候body背景是粉色 */
        @media screen and (max-width:539px) {
            body {
                background-color: pink;
            }
        }
        /* 宽度大于等于540px的时候 body是天蓝色 */
        @media screen and (min-width:540px) {
            body {
                background-color: skyblue;
            }
        }
        /* 宽度大于等于970的时候body是红色 */
        @media screen and (min-width:970px) {
            body {
                background-color: red;
            }
        }
    </style>
</head>
<body>
    
</body>
</html>